package com.kkd.kkdapp.activity;

import com.kkd.kkdapp.R;
import com.kkd.kkdapp.base.BaseActivity;
import com.kkd.kkdapp.utils.PreferenceUtils;
import com.nostra13.universalimageloader.core.ImageLoader;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;

public class CheckMainUrlActivity extends BaseActivity implements
		OnClickListener {

	private ImageView mainUrl;
	private RelativeLayout check_rl;
	private String url;
	private String mode;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mTintManager.setStatusBarTintResource(R.color.black);
		setContentView(R.layout.activity_check_main_url);
		try {
			mode = getIntent().getExtras().getString("mode");
		} catch (Exception e) {
			// 忽略
		}
		if(!TextUtils.isEmpty(mode)&&mode.equals("1")){
			try {
				url = getIntent().getExtras().getString("url");
			} catch (Exception e) {
				// 忽略
			}
			
		}else{
			url = PreferenceUtils.getInstance().getHeadUrl(this);
		}
		
		initView();
		setListener();
	}

	public void initView() {
		mainUrl = (ImageView) this.findViewById(R.id.mainUrl);
		ImageLoader.getInstance().displayImage(url, mainUrl);
		check_rl = (RelativeLayout) this.findViewById(R.id.check_rl);
	}

	public void setListener() {
		check_rl.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {

		switch (v.getId()) {
		case R.id.check_rl:
			finish();
			overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
			break;
		}

	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			finish();
			overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
			return true;
		} else {
			return super.onKeyDown(keyCode, event);
		}
	}
}
